﻿using System;
using System.Drawing;
using System.Windows.Forms;
using ProjectAutumn;

namespace Test_Project
{
    public partial class Form1 : Form
    {
        private const int DEFAULT_WINDOW_SYSTEM = (int)WindowSystems.Form;
        private const int DEFAULT_GRAPHICS_SYSTEM = (int)GraphicsSystems.Direct2D;
        private const int DEFAULT_INPUT_SYSTEM = (int)InputSystems.Null;
        public bool ClickedOK;
        public WindowSystems WantedWindowSystem = WindowSystems.Form;
        public GraphicsSystems WantedGraphicsSystem = GraphicsSystems.Form;
        public InputSystems WantedInputSystem;
        public Form1()
        {
            InitializeComponent();
            foreach (WindowSystems system in Enum.GetValues(typeof(WindowSystems)))
                comboBox1.Items.Add(system);
            foreach (GraphicsSystems system in Enum.GetValues(typeof(GraphicsSystems)))
                comboBox2.Items.Add(system);
            foreach (InputSystems system in Enum.GetValues(typeof(InputSystems)))
            comboBox3.Items.Add(system);
            comboBox1.SelectedIndex = DEFAULT_WINDOW_SYSTEM;
            comboBox2.SelectedIndex = DEFAULT_GRAPHICS_SYSTEM;
            comboBox3.SelectedIndex = DEFAULT_INPUT_SYSTEM;
            comboBox1.SelectedIndexChanged += delegate { TestValidity(); };
            comboBox2.SelectedIndexChanged += delegate { TestValidity(); };
            comboBox3.SelectedIndexChanged += delegate { TestValidity(); };
        }
        private void TestValidity()
        {
            if (Utility.IsValid((WindowSystems)comboBox1.SelectedIndex))
            {
                label8.Text = "Valid";
                label8.ForeColor = Color.Lime;
            }
            else
            {
                label8.Text = "Not Valid";
                label8.ForeColor = Color.Red;
            }
            if (Utility.IsValid((GraphicsSystems)comboBox2.SelectedIndex, (WindowSystems)comboBox1.SelectedIndex))
            {
                label9.Text = "Valid";
                label9.ForeColor = Color.Lime;
            }
            else
            {
                label9.Text = "Not Valid";
                label9.ForeColor = Color.Red;
            }
            if (Utility.IsValid((InputSystems)comboBox3.SelectedIndex, (WindowSystems)comboBox1.SelectedIndex))
            {
                label10.Text = "Valid";
                label10.ForeColor = Color.Lime;
            }
            else
            {
                label10.Text = "Not Valid";
                label10.ForeColor = Color.Red;
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text += Utility.GetOSName(Utility.GetOS());
            label2.Text += Utility.OnMono();
            label4.Text += Utility.GetDirectXVersion();
            TestValidity();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ClickedOK = true;
            WantedWindowSystem = (WindowSystems)comboBox1.SelectedIndex;
            WantedGraphicsSystem = (GraphicsSystems)comboBox2.SelectedIndex;
            WantedInputSystem = (InputSystems)comboBox3.SelectedIndex;
            if (label8.Text == "Not Valid" || label9.Text == "Not Valid" || label10.Text == "Not Valid")
            {
                MessageBox.Show("Combination is invalid");
                return;
            }
            Close();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string message = Utility.IsValidDetails((WindowSystems)comboBox1.SelectedIndex);
            MessageBox.Show(message);
        }
        private void button4_Click(object sender, EventArgs e)
        {
            string message = Utility.IsValidDetails((GraphicsSystems)comboBox2.SelectedIndex, (WindowSystems)comboBox1.SelectedIndex);
            MessageBox.Show(message);
        }
        private void button5_Click(object sender, EventArgs e)
        {
            string message = Utility.IsValidDetails((InputSystems)comboBox3.SelectedIndex, (WindowSystems)comboBox1.SelectedIndex);
            MessageBox.Show(message);
        }
    }
}
